using UnityEngine;

namespace Coffee.UIExtensions
{
    // [Assembly-CSharp.dll].Coffee.UIExtensions.UITransitionEffect
    public class UITransitionEffect : UIEffectBase
    {
        
        #region Coffee.UIExtensions.UITransitionEffect.EffectMode
        // [Assembly-CSharp.dll].Coffee.UIExtensions.UITransitionEffect.EffectMode
        public enum EffectMode
        {
            // Fields
            Fade = 1
            ,Cutoff = 2
            ,Dissolve = 3
            
        
        }
        
        #endregion
        
        // Fields
        public const string shaderName = "UI/Hidden/UI-Effect-Transition";
        private static readonly Coffee.UIExtensions.ParameterTexture _ptex;
        private Coffee.UIExtensions.UITransitionEffect.EffectMode m_EffectMode;
        private float m_EffectFactor;
        private UnityEngine.Texture m_TransitionTexture;
        private Coffee.UIExtensions.EffectArea m_EffectArea;
        private bool m_KeepAspectRatio;
        private float m_DissolveWidth;
        private float m_DissolveSoftness;
        private UnityEngine.Color m_DissolveColor;
        private bool m_PassRayOnHidden;
        private Coffee.UIExtensions.EffectPlayer m_Player;
        private Coffee.UIExtensions.MaterialCache _materialCache;
        
        // Properties
        public float effectFactor { get; set; }
        public UnityEngine.Texture transitionTexture { get; set; }
        public Coffee.UIExtensions.UITransitionEffect.EffectMode effectMode { get; }
        public bool keepAspectRatio { get; set; }
        public override Coffee.UIExtensions.ParameterTexture ptex { get; }
        public float dissolveWidth { get; set; }
        public float dissolveSoftness { get; set; }
        public UnityEngine.Color dissolveColor { get; set; }
        public float duration { get; set; }
        public bool passRayOnHidden { get; set; }
        public UnityEngine.AnimatorUpdateMode updateMode { get; set; }
        private Coffee.UIExtensions.EffectPlayer _player { get; }
        
        // Methods
        public float get_effectFactor()
        {
            return (float)this.m_EffectFactor;
        }
        public void set_effectFactor(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_EffectFactor);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_EffectFactor) < 0)
            {
                    return;
            }
            
            this.m_EffectFactor = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UITransitionEffect).__il2cppRuntimeField_2D8;
        }
        public UnityEngine.Texture get_transitionTexture()
        {
            return (UnityEngine.Texture)this.m_TransitionTexture;
        }
        public void set_transitionTexture(UnityEngine.Texture value)
        {
            UnityEngine.Object val_10;
            UnityEngine.Texture val_11;
            val_10 = value;
            val_11 = this.m_TransitionTexture;
            if(val_11 == val_10)
            {
                    return;
            }
            
            this.m_TransitionTexture = val_10;
            val_10 = this.graphic;
            if((UnityEngine.Object.op_Implicit(exists:  val_10)) == false)
            {
                    return;
            }
            
            val_10 = ???;
            val_11 = ???;
            goto typeof(Coffee.UIExtensions.UITransitionEffect).__il2cppRuntimeField_2C8;
        }
        public Coffee.UIExtensions.UITransitionEffect.EffectMode get_effectMode()
        {
            return (Coffee.UIExtensions.UITransitionEffect.Coffee.UIExtensions.UITransitionEffect.EffectMode)this.m_EffectMode;
        }
        public bool get_keepAspectRatio()
        {
            return (bool)this.m_KeepAspectRatio;
        }
        public void set_keepAspectRatio(bool value)
        {
            bool val_1 = value;
            if(this.m_KeepAspectRatio == val_1)
            {
                    return;
            }
            
            this.m_KeepAspectRatio = val_1;
            UnityEngine.UI.Graphic val_2 = this.targetGraphic;
            goto typeof(UnityEngine.UI.Graphic).__il2cppRuntimeField_2F8;
        }
        public override Coffee.UIExtensions.ParameterTexture get_ptex()
        {
            if(mem[536895099] != 0)
            {
                    return (Coffee.UIExtensions.ParameterTexture)mem[536895059];
            }
            
            536894875 = 536894875;
            return (Coffee.UIExtensions.ParameterTexture)mem[536895059];
        }
        public float get_dissolveWidth()
        {
            return (float)this.m_DissolveWidth;
        }
        public void set_dissolveWidth(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_DissolveWidth);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_DissolveWidth) < 0)
            {
                    return;
            }
            
            this.m_DissolveWidth = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UITransitionEffect).__il2cppRuntimeField_2D8;
        }
        public float get_dissolveSoftness()
        {
            return (float)this.m_DissolveSoftness;
        }
        public void set_dissolveSoftness(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_DissolveSoftness);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_DissolveSoftness) < 0)
            {
                    return;
            }
            
            this.m_DissolveSoftness = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UITransitionEffect).__il2cppRuntimeField_2D8;
        }
        public UnityEngine.Color get_dissolveColor()
        {
            return new UnityEngine.Color() {r = this.m_DissolveColor};
        }
        public void set_dissolveColor(UnityEngine.Color value)
        {
            UnityEngine.Color val_5 = this.m_DissolveColor;
            val_5 = val_5 - value.r;
            float val_1 = S5 - value.g;
            val_5 = val_5 * val_5;
            val_1 = val_1 * val_1;
            val_5 = val_5 + val_1;
            float val_2 = S6 - value.b;
            val_2 = val_2 * val_2;
            val_5 = val_2 + val_5;
            val_5 = ((S7 - value.a) * (S7 - value.a)) + val_5;
            if(val_5 < 0)
            {
                    return;
            }
            
            this.m_DissolveColor = value;
            mem[1152921504930430492] = value.g;
            mem[1152921504930430496] = value.b;
            mem[1152921504930430500] = value.a;
            goto typeof(Coffee.UIExtensions.UITransitionEffect).__il2cppRuntimeField_2D8;
        }
        public float get_duration()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            return (float)val_1.duration;
        }
        public void set_duration(float value)
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.duration = 0.1f;
        }
        public bool get_passRayOnHidden()
        {
            return (bool)this.m_PassRayOnHidden;
        }
        public void set_passRayOnHidden(bool value)
        {
            this.m_PassRayOnHidden = value;
        }
        public UnityEngine.AnimatorUpdateMode get_updateMode()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            return (UnityEngine.AnimatorUpdateMode)val_1.updateMode;
        }
        public void set_updateMode(UnityEngine.AnimatorUpdateMode value)
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.updateMode = value;
        }
        public void Show()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.loop = false;
            System.Action<System.Single> val_3 = 536873435;
            val_3 = new System.Action<System.Single>(object:  this, method:  1610679359);
            this._player.Play(callback:  val_3);
        }
        public void Hide()
        {
            Coffee.UIExtensions.EffectPlayer val_1 = this._player;
            val_1.loop = false;
            System.Action<System.Single> val_3 = 536873435;
            val_3 = new System.Action<System.Single>(object:  this, method:  1610679361);
            this._player.Play(callback:  val_3);
        }
        public override void ModifyMaterial()
        {
            object val_13;
            UnityEngine.Texture val_14;
            Coffee.UIExtensions.MaterialCache val_15;
            val_13 = this;
            if((UnityEngine.Object.op_Implicit(exists:  this.m_TransitionTexture)) != false)
            {
                    val_14 = this.m_TransitionTexture;
                int val_2 = val_14.GetInstanceID();
            }
            else
            {
                    val_14 = 0;
            }
            
            if(this._materialCache != null)
            {
                    if(this._materialCache._hash_k__BackingField == 8589934592)
            {
                    if(this.isActiveAndEnabled != false)
            {
                    if((UnityEngine.Object.op_Implicit(exists:  X22)) == true)
            {
                goto label_9;
            }
            
            }
            
            }
            
                val_15 = this._materialCache;
                Coffee.UIExtensions.MaterialCache.Unregister(cache:  val_15);
                this._materialCache = 0;
            }
            
            label_9:
            if((this.isActiveAndEnabled == false) || ((UnityEngine.Object.op_Implicit(exists:  val_15)) == false))
            {
                goto label_13;
            }
            
            val_15 = this.m_TransitionTexture;
            if((UnityEngine.Object.op_Implicit(exists:  val_15)) == false)
            {
                goto label_15;
            }
            
            if(this._materialCache != null)
            {
                    if(11993091 == 8589934592)
            {
                goto label_17;
            }
            
            }
            
            val_15 = this.m_TransitionTexture;
            System.Func<System.Object> val_8 = 536874841;
            val_8 = new System.Func<System.Object>(object:  this, method:  1610679363);
            this._materialCache = Coffee.UIExtensions.MaterialCache.Register(hash:  8589934592, texture:  val_15, onCreateMaterial:  val_8);
            label_17:
            UnityEngine.UI.Graphic val_10 = this.graphic;
            goto label_22;
            label_13:
            UnityEngine.UI.Graphic val_11 = this.graphic;
            label_25:
            label_22:
            val_13 = ???;
            goto typeof(UnityEngine.UI.Graphic).__il2cppRuntimeField_348;
            label_15:
            UnityEngine.UI.Graphic val_12 = val_13.graphic;
            goto label_25;
        }
        public override void ModifyMesh(UnityEngine.UI.VertexHelper vh)
        {
            Coffee.UIExtensions.IParameterTexture val_15;
            float val_16;
            float val_17;
            var val_19;
            var val_20;
            float val_21;
            val_15 = this;
            if(this.isActiveAndEnabled == false)
            {
                    return;
            }
            
            val_16 = -1f;
            if(this.m_KeepAspectRatio != false)
            {
                    if((UnityEngine.Object.op_Implicit(exists:  this.m_TransitionTexture)) != false)
            {
                    val_17 = (float)this.m_TransitionTexture;
                val_16 = (float)this.m_TransitionTexture / val_17;
            }
            
            }
            
            UnityEngine.Rect val_4 = Coffee.UIExtensions.EffectAreaExtensions.GetEffectArea(area:  this.m_EffectArea, vh:  vh, graphic:  this.graphic, aspectRatio:  val_16);
            UnityEngine.UI.Graphic val_6 = this.graphic;
            int val_7 = vh.currentVertCount;
            if(val_7 < 1)
            {
                    return;
            }
            
            val_15 = val_7;
            var val_16 = 0;
            label_19:
            vh.PopulateUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, normal = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, tangent = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv1 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv2 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv3 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}}, i:  0);
            if(0 == 0)
            {
                goto label_13;
            }
            
            val_19 = 536894795;
            if(mem[536895019] == 0)
            {
                    val_19 = 536894795;
            }
            
            var val_15 = mem[536894979];
            var val_8 = val_16 & 3;
            if(val_8 >= (mem[536894979] + 24))
            {
                goto label_16;
            }
            
            val_15 = val_15 + val_8;
            val_20 = mem[(mem[536894979] + (0 & 3)) + 32];
            val_20 = (mem[536894979] + (0 & 3)) + 32;
            val_21 = mem[(mem[536894979] + (0 & 3)) + 32 + 4];
            val_21 = (mem[536894979] + (0 & 3)) + 32 + 4;
            goto label_18;
            label_13:
            float val_9 = val_4.m_XMin.width;
            val_9 = 0f / val_9;
            val_9 = val_9 + 0.5f;
            val_21 = 0f;
            float val_11 = val_4.m_XMin.height;
            val_11 = 0f / val_11;
            val_11 = val_11 + 0.5f;
            label_18:
            float val_12 = Packer.ToFloat(x:  0f, y:  0f);
            float val_13 = Packer.ToFloat(x:  (val_9 >= 0) ? val_4.m_YMin : (val_21), y:  val_21, z:  this.GetNormalizedIndex(target:  this));
            vh.SetUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3(), normal = new UnityEngine.Vector3(), tangent = new UnityEngine.Vector4(), color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4(), uv1 = new UnityEngine.Vector4(), uv2 = new UnityEngine.Vector4(), uv3 = new UnityEngine.Vector4()}, i:  0);
            val_16 = val_16 + 1;
            if(val_15 != val_16)
            {
                goto label_19;
            }
            
            return;
            label_16:
        }
        protected override void OnEnable()
        {
            this.OnEnable();
            this._player.OnEnable(callback:  0);
            Coffee.UIExtensions.EffectPlayer val_2 = this._player;
            val_2.loop = false;
        }
        protected override void OnDisable()
        {
            Coffee.UIExtensions.MaterialCache.Unregister(cache:  this._materialCache);
            this._materialCache = 0;
            this.OnDisable();
            this._player.OnDisable();
        }
        protected override void SetDirty()
        {
            this.RegisterMaterial(mat:  this.targetGraphic);
            this.SetData(target:  this, channelId:  0, value:  this.m_EffectFactor);
            if(this.m_EffectMode == 3)
            {
                    this.SetData(target:  this, channelId:  1, value:  this.m_DissolveWidth);
                this.SetData(target:  this, channelId:  2, value:  this.m_DissolveSoftness);
                this.SetData(target:  this, channelId:  4, value:  this.m_DissolveColor);
                this.SetData(target:  this, channelId:  5, value:  this.m_DissolveColor);
                this.SetData(target:  this, channelId:  6, value:  this.m_DissolveColor);
            }
            
            if(this.m_PassRayOnHidden == false)
            {
                    return;
            }
            
            UnityEngine.UI.Graphic val_2 = this.graphic;
            var val_3 = (this.m_EffectFactor > 0f) ? 1 : 0;
            goto typeof(UnityEngine.UI.Graphic).__il2cppRuntimeField_2C8;
        }
        private Coffee.UIExtensions.EffectPlayer get__player()
        {
            Coffee.UIExtensions.EffectPlayer val_2 = this.m_Player;
            if(val_2 != null)
            {
                    return val_2;
            }
            
            Coffee.UIExtensions.EffectPlayer val_1 = 536885475;
            val_2 = val_1;
            val_1 = new Coffee.UIExtensions.EffectPlayer();
            this.m_Player = val_2;
            return val_2;
        }
        public UITransitionEffect()
        {
            this.m_EffectMode = 2;
            this.m_DissolveWidth = ;
            this.m_DissolveSoftness = ;
            this.m_DissolveColor = 4503599627370496000;
            mem[1152921504930430496] = 4575657222473777152;
            if(mem[536895019] != 0)
            {
                    return;
            }
        
        }
        private static UITransitionEffect()
        {
            Coffee.UIExtensions.ParameterTexture val_1 = 536890543;
            val_1 = new Coffee.UIExtensions.ParameterTexture(channels:  8, instanceLimit:  128, propertyName:  -1610600767);
            mem2[0] = val_1;
            throw new NullReferenceException();
        }
        private void <Show>b__44_0(float f)
        {
            this.effectFactor = f;
        }
        private void <Hide>b__45_0(float f)
        {
            f = 1f - f;
            this.effectFactor = f;
        }
        private UnityEngine.Material <ModifyMaterial>b__46_0()
        {
            UnityEngine.Material val_1 = 536889313;
            val_1 = new UnityEngine.Material(source:  28164096);
            val_1.name = val_1.name + -1610600873(-1610600873) + this.m_TransitionTexture.name;
            val_1.SetTexture(name:  -1610600719, value:  this.m_TransitionTexture);
            return val_1;
        }
    
    }

}
